'use strict';

import { Application } from 'egg'
import parameter_validate from './utils/parameter_validate'
import { set } from 'mongoose'

set('useCreateIndex', true)

export default (app: Application) => {



  app.once('server', () => {
    // websocket
  });
  app.on('error', () => {
    console.log('app - err = ');
    // report error
  });
  app.on('request', err => {
    // log receive request
    console.log('app request = ', err.req.url);
  });
  app.on('response', () => {
    // ctx.starttime is set by framework
    // log total cost
  });

  /**
   * 自定义参数校验
   */
  parameter_validate(app);
};
